package modelo;

import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;



public class LectorFicheros {

	public static List<java.util.Hashtable> read() {
		try {
			List<java.util.Hashtable> list= new ArrayList<java.util.Hashtable>();
			FileReader file = new FileReader("configuration.conf");
			Scanner scanner = new Scanner(file);

			while (scanner.hasNextLine()){
				java.util.Hashtable hashFile = new java.util.Hashtable();

				boolean end=false;

				while ((scanner.hasNextLine())&&(!end)) {
					end=scanner.hasNext(":");
					String name = "", value=""; 	
					Scanner line = new Scanner(scanner.nextLine());
					line.useDelimiter("=");			
					if(line.hasNext())
						name = line.next();				
					if(!name.startsWith("#") & line.hasNext()){
						value = line.next();
						hashFile.put(name.trim(), value.trim());
					}
					line.close();
				}
				list.add(hashFile);
			}
			scanner.close();
			file.close();
			return list;
		}
		catch (IOException e) {
			e.printStackTrace();
			return null;
		}	
	}

//TODO: tenemos que crear la lectura del fichero de creacion del tablero desde un fichero de configuracion que lleve a su vez JARGS
	
	
	
	
	
}
